from django import forms


class BootStrap(object):
    BootStrap_exclude = []
    def __init__(self,*args,**kwargs):
        super().__init__(*args,**kwargs)
        for name,field in self.fields.items():
            if name in self.BootStrap_exclude:
                continue
            old_class = field.widget.attrs.get("class",'')

            field.widget.attrs = {'class': '{} form-control'.format(old_class), "placeholder": '请输入'+field.label}


class BootStrapForm(BootStrap,forms.Form):
    pass

class BootStrapModelForm(BootStrap,forms.ModelForm):
    pass